﻿//********************************************************************************//
//创建日期：<创建日期，2016-06-12>
//创建作者：<郭登杰，guodengjie@shanghai3h.com>
//功能说明：支票现金付委 到账明细 地下水
//********************************************************************************//
layui.use(['form', 'jquery', 'element', 'laydate'], function () {
    var form = layui.form()
    , layer = layui.layer
    , $ = layui.jquery
    , element = layui.element()
    , laydate = layui.laydate;
    /*initial load start*/
    initcontrol();
    load();
    /*initial load end*/

    /*initial*/
    function initcontrol() {        
        //获取当前账务年月
        $.ajax({
            type: "post",
            cache: false,
            async: false,
            url: "/ashx/Common.ashx",
            data: {
                "op": "QSZWYM"
            },
            dataType: "json",
            success: function (rs) {
                $("#cZWYM").val(rs.Data1);
            },
            error: function (error) {
                layer.msg(error.responseText);
            }
        });
    }    
    /*end initial*/

    /*event*/
    $("#oSearch").click(function () {
            load();
    });
    $("#cZWYM").keypress(function () {
        if (event.keyCode == 13) {
            setTimeout(function () {

            }, 0);
            event.preventDefault ? event.preventDefault() : (event.returnValue = false);
            load();
        }
    });
    

    function load() {
        var zwym = $("#cZWYM").val();
        var rss = "";
        $.ajax({
            type: "post",
            cache: false,
            async: false,
            url: "/ashx/QSSFZW/ZhangDan.ashx",
            data: {
                "op": "DXS_SFXX_MX",
                "zwym": zwym
            },
            dataType: "json",
            success: function (rs) {
                rss = rs;
            },
            error: function (error) {
                layer.msg(error.responseText);
            }
        });
        $("#ContentList1").find(".datarow").remove();
        if (rss.length > 0) {
            chunk(rss, list1Create, null);
        }
        else {
            $("#ls1Count").text("0");
            $("#ls1JESum").text("0.00");
        }
    } 
    function list1Create(rs, i) {
        $("#ContentList1").append(createItemStr1(rs));
        $("#ls1Count").text($("#ContentList1 .datarow").length);
        var jeSum = 0;
        $("#ContentList1 .datarow").each(function () {
            jeSum = jeSum + parseFloat($(this).find("td").eq(5).text());
        });
        $("#ls1JESum").text(jeSum.toFixed(2));
    }
    function createItemStr1(obj) {
        var str = $("#ItemStr1 tr").prop("outerHTML");
        var itemstr, zdbh, ym, yhh, yhm, ym, zwym, sfje, sffs,sfrq;
        zdbh = obj["S_ZHANGDANBH"];
        ym = obj["I_YM"];
        yhh = obj["S_YONGHUH"];
        yhm = obj["S_YONGHUM"];
        sfje = obj["N_SHOUFEIJE"];
        zwym = obj["I_ZWYM"];
        sffs = obj["S_SHOUFEIFS"];
        sfrq=obj["D_SHOUFEIRQ"]["DateString"];
        itemstr = str.replace(new RegExp("objZDBH", "gm"), zdbh)
                        .replace(new RegExp("objYHH", "gm"), yhh)
                        .replace(new RegExp("objYHM", "gm"), yhm)
                        .replace(new RegExp("objYM", "gm"), ym)
                        .replace(new RegExp("objZWYM", "gm"), zwym)
                        .replace(new RegExp("objJE", "gm"), sfje.toFixed(2))
                        .replace(new RegExp("objSFFS", "gm"), sffs)
                        .replace(new RegExp("objSFRQ", "gm"), sfrq)
        ;
        return itemstr;
    }
    /*event end*/

    function verify() {
        return true;
    }

    /*logic end*/
});